package com.borball.store.dao;

import org.apache.ibatis.session.SqlSession;

import com.borball.store.domain.ProductStore;
import com.borball.store.util.SessionFactory;

public class ProductStoreDAO extends AbstractDAO<ProductStore> {

	public void updateStore(ProductStore t) {
		SqlSession session = SessionFactory.getInstance().getSqlSessionFactory().openSession();

		try {
			session.update(clazz.getName() + ".updateStore", t);
		} finally {
			session.commit(true);
			session.close();
		}
	}
	
	public int findSumAmount() {
		SqlSession session = SessionFactory.getInstance().getSqlSessionFactory().openSession();

		try {
			Object o = session.selectOne(clazz.getName() + ".getSumAmount");
			if(o == null)
				return 0;
			else 
				return (Integer) o ;
		} finally {
			session.close();
		}
	}
}
